import request from '@/utils/request'

/**
 * 获取文件上传列表
 */
export function queryFileList(data) {
  return request({
    baseURL: '/API-ENTERPRISE-BACKEND/',
    url: '/backend/pictureBank/queryPage',
    method: 'post',
    data
  })
}

/**
 * 删除上传文件
 */
export function deleteFile(data) {
  return request({
    baseURL: '/API-ENTERPRISE-BACKEND/',
    url: '/backend/pictureBank/deleteById',
    method: 'post',
    data
  })
}

/**
 * 新增文件
 */
export function addFile(data, type) {
  const url = type === 'created' ? '/backend/pictureBank/insert' : '/backend/pictureBank/update'
  return request({
    baseURL: '/API-ENTERPRISE-BACKEND/',
    url: url,
    method: 'post',
    data
  })
}

/**
 * 修改文件状态
 */
export function setStatus(data) {
  return request({
    baseURL: '/API-ENTERPRISE-BACKEND/',
    url: '/backend/pictureBank/updateStatus',
    method: 'post',
    data
  })
}

/**
 * 字典
 */
export function getDictByCode(dictCode) {
  return request({
    baseURL: '/API-ENTERPRISE-BACKEND/',
    url: '/backend/sysDictionary/getDictByCode',
    method: 'get',
    params: { dictCode }
  })
}

/**
 * 获取分类树形列表
 */
export function getClassifyTree(data) {
  return request({
    baseURL: '/API-ENTERPRISE-BACKEND/',
    url: '/backend/sysClassify/getClassifyTree',
    method: 'POST',
    data
  })
}

/**
 * 批量设置名称、分类
 */
export function batchSetting(data) {
  return request({
    baseURL: '/API-ENTERPRISE-BACKEND/',
    url: '/backend/pictureBank/updateBatch',
    method: 'POST',
    data
  })
}
